package com.pass.util.dialog;

import android.content.Context;
import android.content.DialogInterface;

import androidx.appcompat.app.AlertDialog;

public class DialogUtil {


    public static void simpleDialog(Context context, String msgStr, String cancelStr, String sureStr, DialogInterface.OnClickListener sureListener) {
        AlertDialog dialog = new AlertDialog.Builder(context).setCancelable(false).setTitle("提示").setMessage(msgStr).setNegativeButton(cancelStr, (dialog1, which) -> dialog1.cancel()).setPositiveButton(sureStr, sureListener).create();
        dialog.show();
    }


    public static void simpleDialog(Context context, String titleStr, String msgStr, String cancelStr, String sureStr, DialogInterface.OnClickListener cancelListener, DialogInterface.OnClickListener sureListener) {
        AlertDialog dialog = new AlertDialog.Builder(context).setTitle(titleStr)//设置对话框的标题
                .setMessage(msgStr).setNegativeButton(cancelStr, cancelListener).setPositiveButton(sureStr, sureListener).create();
        dialog.show();
    }

    public static void simpleDialog(Context context, String titleStr, String msgStr, DialogInterface.OnClickListener cancelListener, DialogInterface.OnClickListener sureListener) {
        AlertDialog dialog = new AlertDialog.Builder(context).setTitle(titleStr)//设置对话框的标题
                .setMessage(msgStr).setNegativeButton("取消", cancelListener).setPositiveButton("确定", sureListener).create();
        System.out.println("DialogUtil.simpleDialog");
        dialog.show();
    }

    public static void simpleDialog(Context context, String titleStr, String msgStr, DialogInterface.OnClickListener sureListener) {
        AlertDialog dialog;//设置对话框的标题
        if (null != sureListener) {
            dialog = new AlertDialog.Builder(context).setTitle(null == titleStr ? "提示" : titleStr)//设置对话框的标题
                    .setMessage(msgStr).setPositiveButton("确定", sureListener).create();
        } else {
            dialog = new AlertDialog.Builder(context).setTitle(null == titleStr ? "提示" : titleStr)//设置对话框的标题
                    .setMessage(msgStr).setPositiveButton("确定", (dialog1, which) -> dialog1.dismiss()).create();
        }
        dialog.show();
    }
}
